class Node {
    public int val;
    public Node next;
    public Node(int val) {
        this.val = val;
    }
}


public class MyQueue {
    public Node head;
    public Node last;

    /**
     * 尾插法
     * @param val
     */
    public void offer(int val) {
        Node node = new Node(val);
        if (head == null) {
            head = node;
            last = node;
        }else {
            last.next = node;
            last = node;
        }
    }
//      删除队头节点
    public int poll() {
        if (isEmpty()) {
            throw new RuntimeException();
        }
        int oldVal = this.head.val;
        this.head = this.head.next;
        return oldVal;
    }
//    判断是否为空
    public boolean isEmpty() {
        return this.head == null;
    }
//    查看头结点
    public int peek() {
        if (isEmpty()) {
            throw new RuntimeException();
        }
        int oldVal = this.head.val;
        return oldVal;
    }
}
